import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false

// vuex
import store from '@/store/index.js'
// router
import router from '@/router/index.js'
router.beforeEach((to, from, next) => {
  //console.log(to);
  if (to.path.toLowerCase() === '/login') return next();
  if (to.path.toLowerCase()  === '/help') return next();
  if (to.path.toLowerCase()  === '/about') return next();
  //判断是否登录
  const token = window.sessionStorage.getItem('Token')
  //token不存在就强制跳转到登录
  if (!token) {    
      return next('/login')
  }
  //防止重复登录
  if(token&&to.path.toLocaleLowerCase()=='login')
  {
      return next('/login')
  }
       //放行
  next();
})
// element-ui
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

Vue.prototype.$host = 'http://localhost:51154/'
Vue.prototype.$img = 'http://localhost:51154'



new Vue({
  store,
  router,
  render: h => h(App),
}).$mount('#app')
